<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>粘性定位</title>
    <!-- 相对定位和绝对定位的结合 -->
    <style>
        body {
            height: 3000px;
        }

        .nav {
            background-color: rgb(185, 114, 20);
            width: 200px;
            height: 20px;
            position: sticky;
            top: 0;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <div class="nav">
        我是粘性定位的应用。
    </div>
</body>

</html>